var e = require;
var t = module;
var o = exports;
var ii, nn = this && this.__extends || (ii = function (t, e) {
    return (ii = Object.setPrototypeOf || {
        __proto__: []
    }
        instanceof Array &&
        function (t, e) {
            t.__proto__ = e
        } ||
        function (t, e) {
            for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o])
        })(t, e)
},
    function (t, e) {
        function o() {
            this.constructor = t
        }
        ii(t, e),
            t.prototype = null === e ? Object.create(e) : (o.prototype = e.prototype, new o)
    }
),
    rr = this && this.__awaiter ||
        function (t, e, o, i) {
            return new (o || (o = Promise))(function (n, a) {
                function r(t) {
                    try {
                        l(i.next(t))
                    } catch (e) {
                        a(e)
                    }
                }
                function s(t) {
                    try {
                        l(i.
                            throw(t))
                    } catch (e) {
                        a(e)
                    }
                }
                function l(t) {
                    var e;
                    t.done ? n(t.value) : (e = t.value, e instanceof o ? e : new o(function (t) {
                        t(e)
                    })).then(r, s)
                }
                l((i = i.apply(t, e || [])).next())
            })
        };
var oo = (this && this.__decorate) ||
    function (e, t, a, n) {
        var i,
            o = arguments.length,
            s = o < 3 ? t : null === n ? (n = Object.getOwnPropertyDescriptor(t, a)) : n;
        if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) s = Reflect.decorate(e, t, a, n);
        else
            for (var r = e.length - 1; r >= 0; r--)
                (i = e[r]) && (s = (o < 3 ? i(s) : o > 3 ? i(t, a, s) : i(t, a)) || s);
        return o > 3 && s && Object.defineProperty(t, a, s), s;
    };
Object.defineProperty(o, "__esModule", { value: !0 }), (o.ResultEnum = void 0);
var a,
    n = e("UIManager"),
    i = e("ASCAd"),
    r = e("sdkConfig"),
    s = e("MiniGameSDK"),
    l = e("Toast"),
    _ = cc._decorator,
    c = _.ccclass;
(function (e) {
    (e[(e.Success = 1)] = "Success"), (e[(e.Fail = 2)] = "Fail");
})((a = o.ResultEnum || (o.ResultEnum = {})));
var d = (function () {
    function e() {
        this.isBackground = !1;
    }
    var t;
    return (
        (t = e),
        (e.getInstance = function () {
            return t.instance || (t.instance = new t()), t.instance;
        }),
        (e.prototype.init = function (e) {
            // -1 !=
            //     [
            //         r.EPlatform.VIVO,
            //         r.EPlatform.OPPO,
            //         r.EPlatform.TikTok,
            //         r.EPlatform.KWAI_GAME,
            //         r.EPlatform.BOX_4399,
            //         r.EPlatform.NET_4399,
            //         r.EPlatform.UC
            //     ].indexOf(r.default.platform)
            //     ? (i.default.getInstance().initAd(),
            //         e && e(),
            //         this.NetworkSubscribe(),
            //         this.AdLog("接入数据上报"),
            //         s.default.onApplication(this.onApplication.bind(this)))
            //     : r.default.platform == r.EPlatform.NO_AD && e && e();
            console.log("xxxxxxxxxxxxxxxxx-init");
            e && e();
        }),
        (e.prototype.NetworkSubscribe = function () {
            s.default.subscribeNetworkStatus(function (e) {
                e ||
                    s.default.showDialog("提示", "无网络，请退出游戏重启网络", function () {
                        s.default.exitApplication();
                    });
            });
        }),
        (e.prototype.onApplication = function (e) {
            if (e) {
                var t = this;
                this.AdLog("游戏进入前台"),
                    setTimeout(function () {
                        t.isBackground = !1;
                    }, 2e3);
            } else (this.isBackground = !0), this.AdLog("游戏进入后台");
        }),
        Object.defineProperty(e.prototype, "videoFlag", {
            get: function () {
                return true
                // (
                //     -1 !=
                //     [r.EPlatform.VIVO, r.EPlatform.OPPO, r.EPlatform.TikTok, r.EPlatform.KWAI_GAME].indexOf(
                //         r.default.platform
                //     ) && i.default.getInstance().getVideoFlag()
                // );
            },
            enumerable: !1,
            configurable: !0
        }),
        (e.prototype.showVideo = function (e) {
            var t = this;
            if ((this.AdLog("调用展示 视频"), r.default.platform == r.EPlatform.NO_AD))
                return this.gameTaskInfo(), void e(a.Success);
            // cc.director.pause(),
            -1 !=
                [r.EPlatform.VIVO, r.EPlatform.OPPO, r.EPlatform.TikTok, r.EPlatform.KWAI_GAME].indexOf(
                    r.default.platform
                ) &&
                (this.videoFlag
                    ? (this.AdLog("视频开关已开，调用展示视频成功"),
                        i.default.getInstance().showVideo(function (o) {
                            // t.AdLog("视频打开完成，视频回调结果：" + o),
                            //     cc.director.resume(),
                            //     null == o
                            //         ? (l.default.showNewToast("暂无视频"), e(a.Fail))
                            //         : o
                            //             ? (t.gameTaskInfo(), e(a.Success))
                            //             : e(a.Fail);
                            (t.gameTaskInfo(), e(a.Success));
                        }))
                    : (this.AdLog("视频开关关闭"),
                        cc.director.resume(),
                        l.default.showNewToast("暂无视频"),
                        e(a.Fail)));
        }),
        (e.prototype.gameTaskInfo = function () {
            cc.find("UIManager").getComponent(n.default).playerTaskOverInfo(10, 1);
        }),
        Object.defineProperty(e.prototype, "interFlag", {
            get: function () {
                return (
                    -1 != [r.EPlatform.VIVO, r.EPlatform.TikTok, r.EPlatform.KWAI_GAME].indexOf(r.default.platform) &&
                    i.default.getInstance().getIntersFlag()
                );
            },
            enumerable: !1,
            configurable: !0
        }),
        (e.prototype.showInter = function () {
            // -1 != [r.EPlatform.VIVO, r.EPlatform.TikTok, r.EPlatform.KWAI_GAME].indexOf(r.default.platform) &&
            //     t.getInstance().interFlag &&
            i.default.getInstance().showInters();
        }),
        (e.prototype.showOppoCustom = function () {
            r.default.platform == r.EPlatform.OPPO && i.default.getInstance().showOppoCustom();
        }),
        (e.prototype.hideCustomAd = function () {
            r.default.platform == r.EPlatform.OPPO && i.default.getInstance().hideCustomAd();
        }),
        (e.prototype.showBanner = function () {
            -1 !=
                [r.EPlatform.VIVO, r.EPlatform.OPPO, r.EPlatform.TikTok, r.EPlatform.KWAI_GAME].indexOf(
                    r.default.platform
                ) && i.default.getInstance().showBanner();
        }),
        (e.prototype.hideBanner = function () {
            -1 !=
                [r.EPlatform.VIVO, r.EPlatform.OPPO, r.EPlatform.TikTok, r.EPlatform.KWAI_GAME].indexOf(
                    r.default.platform
                ) && i.default.getInstance().hideBanner();
        }),
        (e.prototype.getNativeImagerAdFlag = function () {
            var e = !1;
            return (
                (r.default.platform != r.EPlatform.OPPO && r.default.platform != r.EPlatform.VIVO) ||
                (e = i.default.getInstance().getNativeImageAdFlag()),
                console.log("原生大图资源是否加载成功", e),
                e
            );
        }),
        (e.prototype.getNativeIconAdFlag = function () {
            return r.default.platform == r.EPlatform.OPPO || r.default.platform == r.EPlatform.VIVO
                ? i.default.getInstance().getNativeIconAdFlag()
                : null;
        }),
        (e.prototype.getNativeImageInfo = function () {
            return this.getNativeImagerAdFlag()
                ? r.default.platform == r.EPlatform.OPPO || r.default.platform == r.EPlatform.VIVO
                    ? i.default.getInstance().getNativeImageAdInfo()
                    : void 0
                : null;
        }),
        (e.prototype.getNativeIconInfo = function () {
            return this.getNativeIconAdFlag()
                ? r.default.platform == r.EPlatform.OPPO || r.default.platform == r.EPlatform.VIVO
                    ? i.default.getInstance().getNativeIconAdInfo()
                    : void 0
                : null;
        }),
        (e.prototype.reportNativeImageAdShow = function () {
            i.default.getInstance().reportNativeImageAdShow();
        }),
        (e.prototype.reportNativeIconAdShow = function () {
            i.default.getInstance().reportNativeIconAdShow();
        }),
        (e.prototype.nativeImageClick = function () {
            i.default.getInstance().nativeImageClick();
        }),
        (e.prototype.nativeIconClick = function () {
            i.default.getInstance().nativeIconClick();
        }),
        (e.prototype.getNavigateBoxBannerFlag = function () {
            return (
                (r.default.platform == r.EPlatform.OPPO || r.default.platform == r.EPlatform.VIVO) &&
                i.default.getInstance().getNavigateBoxBannerFlag()
            );
        }),
        (e.prototype.showNavigateBoxBanner = function () {
            (r.default.platform != r.EPlatform.OPPO && r.default.platform != r.EPlatform.VIVO) ||
                (i.default.getInstance().getNavigateBoxBannerFlag() && i.default.getInstance().showNavigateBoxBanner());
        }),
        (e.prototype.hideNavigateBoxBanner = function () {
            (r.default.platform != r.EPlatform.OPPO && r.default.platform != r.EPlatform.VIVO) ||
                i.default.getInstance().hideNavigateBoxBanner();
        }),
        (e.prototype.getNavigateBoxPortalFlag = function () {
            var e = !1;
            return (
                (r.default.platform != r.EPlatform.OPPO && r.default.platform != r.EPlatform.VIVO) ||
                (e = i.default.getInstance().getNavigateBoxPortalFlag()),
                e
            );
        }),
        (e.prototype.showNavigateBoxPortal = function () {
            (r.default.platform != r.EPlatform.OPPO && r.default.platform != r.EPlatform.VIVO) ||
                (i.default.getInstance().getNavigateBoxPortalFlag() && i.default.getInstance().showNavigateBoxPortal());
        }),
        (e.prototype.hideNavigateBoxPortal = function () {
            r.default.platform == r.EPlatform.VIVO && i.default.getInstance().hideNavigateBoxPortal();
        }),
        (e.prototype.hasAddDesktopFunc = function () {
            i.default.getInstance().hasAddDesktopFunc();
        }),
        (e.prototype.desktopFlag = function (e) {
            var t = this;
            r.default.platform != r.EPlatform.NO_AD
                ? this.hasAddDesktopFunc &&
                i.default.getInstance().getAddDesktopFlag(function (o) {
                    t.AdLog("the desktopFlag is " + o), e(o ? a.Success : a.Fail);
                })
                : e(a.Success);
        }),
        (e.prototype.addDeskTop = function (e) {
            var t = this;
            (r.default.platform != r.EPlatform.VIVO &&
                r.default.platform != r.EPlatform.OPPO &&
                r.default.platform != r.EPlatform.TikTok) ||
                i.default.getInstance().addDesktop(function (o) {
                    t.AdLog("the addDeskTop is " + o), e(o ? a.Success : a.Fail);
                });
        }),
        (e.prototype.setGroup = function (e) {
            -1 !=
                [
                    r.EPlatform.VIVO,
                    r.EPlatform.OPPO,
                    r.EPlatform.TikTok,
                    r.EPlatform.KWAI_GAME,
                    r.EPlatform.UC,
                    r.EPlatform.NET_4399,
                    r.EPlatform.NET_4399
                ].indexOf(r.default.platform) && i.default.getInstance().setGroup(e);
        }),
        (e.prototype.getGameTestVersion = function () {
            return r.default.platform != r.EPlatform.NO_AD && i.default.getInstance().getGameTestVersion();
        }),
        (e.prototype.vibrateShort = function () {
            r.default.platform != r.EPlatform.NO_AD && i.default.getInstance().phoneVibrate("long");
        }),
        (e.prototype.AdLog = function (e) {
            console.log("ad log广告日志:" + e, "=================");
        }),
        (e.prototype.getNativeImageErrorControl = function () {
            return (
                (r.default.platform == r.EPlatform.VIVO || r.default.platform == r.EPlatform.OPPO) &&
                i.default.getInstance().getNativeImageErrorControl()
            );
        }),
        (e.prototype.getCustomErrorControl = function () {
            if (r.default.platform != r.EPlatform.NO_AD) return i.default.getInstance().getCustomErrorControl();
        }),
        (e.prototype.getErrorControl = function () {
            return r.default.platform == r.EPlatform.NO_AD || i.default.getInstance().getErrorControl();
        }),
        (e.prototype.StartRecorder = function (e) {
            void 0 === e && (e = 300),
                r.default.platform == r.EPlatform.TikTok && i.default.getInstance().StartRecorder(e);
        }),
        (e.prototype.StopRecorder = function (e) {
            void 0 === e && (e = 299),
                r.default.platform == r.EPlatform.TikTok && i.default.getInstance().StopRecorder(e);
        }),
        (e.prototype.ShareVideo = function (e, t) {
            r.default.platform == r.EPlatform.TikTok && i.default.getInstance().ShareVideo(e, t);
        }),
        (e.prototype.RecordClip = function (e, t) {
            r.default.platform == r.EPlatform.TikTok && i.default.getInstance().RecordClip(e, t);
        }),
        (e.prototype.PauseRecorder = function () {
            r.default.platform == r.EPlatform.TikTok && i.default.getInstance().PauseRecorder();
        }),
        (e.prototype.ResumeRecorder = function () {
            r.default.platform == r.EPlatform.TikTok && i.default.getInstance().ResumeRecorder();
        }),
        (e.prototype.creatMoreGameButton = function (e, t) {
            void 0 === t && (t = 720);
        }),
        (e.prototype.showMoreGameButton = function () { }),
        (e.prototype.hideMoreGameButton = function () { }),
        (e.prototype.getGroupFalg = function () {
            var e = !1;
            return r.default.platform == r.EPlatform.TikTok && (e = i.default.getInstance().getGroupFalg()), e;
        }),
        (e.prototype.TiktokJoinGroup = function () {
            this.getGroupFalg() && i.default.getInstance().TiktokJoinGroup();
        }),
        (t = oo([c], e))
    );
})();
o.default = d;
